
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=9" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form action = "" method="post" onclick=" return rebuttal();" >
            Rebuttal:</br></br>
            <textarea name ="rebuttal" cols="40" rows="10"></textarea>  </br>
            <input type="submit" value="send" />
        </form>


        <?php
        session_start();
        if (isset($_GET['paper_id'])) {
            //echo 'in if';
            $member_id = $_SESSION['member_id'];
            ; //$_SESSION['member_id'];// getting the member id
            $paper_id = $_GET['paper_id'];
            $conference_id=$_GET['conference_id'];
            $conn = mysql_connect('localhost', 'root', '') or die(mysql_error());
            mysql_select_db('mydb') or die(mysql_error());
            $date = date('Y-m-d');
            $today = date("Y-m-d H:i:s", strtotime($date));

            //getting the deadline
            $deadline = mysql_query("SELECT `rev_endDate` 
            From`conference`c   
            Where c.`conference_id`='$conference_id'
            ") or die(mysql_error());
            $row1 = mysql_fetch_assoc($deadline);
            $review_enddate = $row1["rev_endDate"];

            if (isset($_POST['rebuttal'])) {

                $rebuttal = $_POST['rebuttal']; // retrieveing the rebuttal text
                if ($rebuttal != "") {
                    if ($today > $review_enddate) {
                        // rebuttaling will be done over the paper_id
                        //ex ecuting a query to enter the rebuttal data into the table rebuttal inserting the paper

                        $InsertRebuttal = mysql_query("
                INSERT INTO a_rebuttal_paper(`member_id`, `paper_id`,`rebuttal_text`)
                  VALUES('$member_id','$paper_id' ,'$rebuttal')
                       ") or die("You have already rebuttaled on this paper");
                        echo " your rebuttal has been successfully sent";
                    } else {
                        echo "You cannot rebuttal yet on this paper, review has not ended";
                    }
                } else {
                    echo "please enter your rebuttal";
                }
            }
        }
        ?>










    </body>
</html>
